import jpl.*;
import java.util.Hashtable;
import java.io.*;

public class Diagnostico {
	public static void main(java.lang.String args[]){
		JPL.init();
		Query query = new Query("consult", new Atom ("SistemaEspecialista.pl"));
		query.query();
		query = new Query("consult", new Atom ("BaseConhecimento.pl"));
		query.query();
		query = new Query("consulta.");
		//query.query();
		

		Reader r = new InputStreamReader(new StringBufferInputStream((String)query.nextElement()));
		query.oneSolution();
		//Hashtable t = query.onesSolution();
		//System.out.println(t.toString());
		//System.out.println(query.oneSolution());
		/*query = new Query("sim.");
		System.out.println(query.oneSolution());
		query = new Query("sim.");
		System.out.println(query.oneSolution());
		query = new Query("sim.");
		System.out.println(query.oneSolution());*/
		/*if ( !query.query() ){
			System.out.println( "consult('testedoencas.pl') failed" );
			System.exit(1);
		}*/
		/*
		Variable Res = new Variable("Res");
		
		Term sintomas = Util.textToTerm("[dordecabeca,malestar]");
		Term[] parte2 = new Term[2];
		parte2[0] = Res;
		parte2[1] = sintomas;
		//Term[] sints = Util.toTermArray(new Atom("dordecabeca"), 
		new Atom("malestar"));
		//Term sintomas = Util.termArrayToList(sints);
		
		Query consultaDoenca = new Query("doenca", parte2);
		
		while(consultaDoenca.hasMoreSolutions()){
			Hashtable solution = consultaDoenca.nextSolution();
			Term t = (Term)solution.get("Res");
			System.out.println(t);
		}
		*/
		
	}
}
